<template>
  <div class="divBox">
    <div class="root">
      <div class="top-title">
        <div class="pro-title">开发进度管理</div>
        <button class="feishu-btn" @click="sendCode">
          打开飞书文档
        </button>
      </div>
      <div class="span-text">
        <span>正在跳转到飞书文档，请稍候...</span>
      </div>
      <div>
        <div id="your-mount-point"></div>
      </div>
    </div>
  </div>
</template>
<script>
import { getAccoutBaseInfo } from "@/api/tenant";
import Cookies from 'js-cookie'

export default {
  name: "projectSchedule",
  data() {
    return {
      baseInfo: {},
      app_id: "cli_a21e705fcc38500c",
      code: "", //测试写死
      openId: "",
      signature: "",
      appId: "",
      timestamp: "",
      nonceStr: "",
      url: "",
      jsApiList: ["DocsComponent"],
      lang: "",
      isShow: false,
      fileUrl: "https://zfx2bso66l.feishu.cn/sheets/shtcnoHokr9Y571RpgiWODMHaHd",
      fileToken: "ur-27Uqh6i414Ia2kfBGkJ6WlggiBy05hK3pi00hhA00fjB",
      //  replaceTextList 高量区数据 textList替换数据  后面再字典加
      positionList: [],
      position: "",
      templateNum: '',
    };
  },
  methods: {
    sendCode() {
      let url = this.fileUrl;
      // 在新窗口中打开飞书文档
      window.open(url, '_blank');
    },
    // 获取用户基本信息
    getUserBaseInfo() {
      try {
        const javaInfo = Cookies.get('JavaInfo');
        if (javaInfo) {
          this.baseInfo = JSON.parse(javaInfo);
        } else {
          // 使用默认的模拟数据
          this.baseInfo = {
            accountId: 'mock_account_001',
            accountName: '测试用户',
            tenantId: 'mock_tenant_001'
          };
        }
      } catch (error) {
        console.error('获取用户信息失败:', error);
        // 使用默认的模拟数据
        this.baseInfo = {
          accountId: 'mock_account_001',
          accountName: '测试用户',
          tenantId: 'mock_tenant_001'
        };
      }
    }
  },
  mounted() {
    this.getUserBaseInfo();
    // 延迟跳转，让用户看到页面内容
    setTimeout(() => {
      this.sendCode();
    }, 1000);
  },
  created() {
    // this.templateNum = this.$route.query.templateNum;
  },
};
</script>
<style scoped>
.divBox {
  margin: 20px;
  background: #f2f5f7;
}

.root {
  padding: 30px;
  background: #ffffff;
  box-shadow: 0px 2px 8px 0px #eaf0f3;
  border-radius: 8px;
  overflow: auto;
  min-height: 400px;
}

.top-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
}

.pro-title {
  font-size: 18px;
  font-weight: 500;
  color: #24A776;
}

.feishu-btn {
  background: #26B581;
  border-radius: 4px;
  padding: 10px 16px;
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.feishu-btn:hover {
  background: #1e9d6b;
  transform: translateY(-1px);
}

.feishu-btn:active {
  opacity: 0.8;
  transform: translateY(0);
}

.span-text {
  text-align: center;
  margin: 40px 0;
}

.span-text > span {
  font-size: 16px;
  font-weight: 400;
  color: #808EA5;
}

.ff-ppc {
  margin: 20px 0;
}

.mag-rl {
  margin: 0px 8px;
}

/* 加载动画 */
.span-text::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #24A776;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 10px;
  vertical-align: middle;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .top-title {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
  
  .feishu-btn {
    width: 100%;
    max-width: 200px;
  }
  
  .root {
    padding: 20px;
  }
}
</style>